package com.design.pattern.simple.factory;

/**
 * @Description 工厂类
 * @author ll
 * @createTime 2021/5/31  22:50 
 */
public class SimpleFaction {

	/**
	 * 工厂方法
	 * 多态+继承
	 * @param string 根据传参不同实例化不同的子类
	 * @return  返回具体的对象
	 */
	public static Operator getOperator(String string){
		Operator operator = null;
		if("+".equals(string)){
			operator = new Add();
		}else if("-".equals(string)){
			operator = new Sub();
		}else if("*".equals(string)){
			operator = new Mul();
		}else if("/".equals(string)){
			operator = new Div();
		}
		return operator;
	}

}
